import rclpy
from rclpy.node import Node
from rclpy.time import Time
from rclpy.duration import Duration

class Mynode(Node):
    def __init__(self):
        super().__init__("operation_node_py")
        self.demo_opt()
    def demo_opt(self):
        t1=Time(seconds=20)
        t2=Time(seconds=5)

        du1=Duration(seconds=7)
        du2=Duration(seconds=13)

        self.get_logger().info(f"t1>=t2,{t1>=t2}")
        self.get_logger().info(f"t1<=t2,{t1<=t2}")
        self.get_logger().info(f"du1>=du2,{du1>=du2}")
        self.get_logger().info(f"du1<=du2,{du1<=du2}")

        t3=t1-t2
        t4=t1+du1
    #   t5=du1+du2  在个运算不存在
        self.get_logger().info(f"t3={t3.nanoseconds}")
        self.get_logger().info(f"t4={t4.nanoseconds}")
    #    self.get_logger().info(f"t5={t5.nanoseconds}")
def main():
    rclpy.init()
    rclpy.spin(Mynode())
    rclpy.shutdown()

if __name__=='__main__':
    main()
        